package com.movie.controller.SysLogController;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.movie.beans.LoginInfo;
import com.movie.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/system/log")
public class SysLogController {
    private static String prefix = "/system/log";
    @Autowired
    private RecordService recordService;
    @GetMapping()
    public String index(){
        return prefix+"/index";
    }

    @PostMapping("/list")
    @ResponseBody
    public Map list(int limit, int page){
        Map map = new HashMap();
        PageHelper.startPage(page,limit);
        List<LoginInfo> infos= recordService.list();
        map.put("msg","");
        map.put("code",0);
        map.put("data",infos);
        map.put("count",new PageInfo(infos).getTotal());
        return map;
    }
}
